<template>
  <div id="app">
    <!-- 管理后台页面（不显示商城头部和页脚） -->
    <div v-if="isAdminPage">
      <router-view />
    </div>
    
    <!-- 商城前台页面 -->
    <div v-else class="page-wrapper">
      <!-- 应用头部 -->
      <AppHeader />

      <!-- 页面内容 -->
      <div id="page-content">
        <router-view />
      </div>

      <!-- 页脚 -->
      <footer class="footer mt-auto py-4 bg-dark text-light">
        <div class="container">
          <div class="row">
            <div class="col-md-6">
              <p>&copy; 2025 SHOPLOOK 商城系统</p>
            </div>
          </div>
        </div>
      </footer>
    </div>
  </div>
</template>

<script setup lang="ts">
import { onMounted, computed } from 'vue'
import { useRoute } from 'vue-router'
import AppHeader from '@/components/AppHeader.vue'
import { useUserStore } from '@/stores/user'

const route = useRoute()
const userStore = useUserStore()

// 判断是否为管理后台页面
const isAdminPage = computed(() => {
  return route.path.startsWith('/admin')
})

onMounted(() => {
  // 初始化用户信息
  userStore.initUserInfo()
})
</script>

<style>
/* 全局样式重置 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Helvetica Neue', Helvetica, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', '微软雅黑', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background-color: #fff;
  line-height: 1.6;
}

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Bootstrap和Element Plus兼容性调整 */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 15px;
}

.row {
  display: flex;
  flex-wrap: wrap;
  margin: 0 -15px;
}

.col-12 {
  flex: 0 0 100%;
  max-width: 100%;
  padding: 0 15px;
}

.col-11 {
  flex: 0 0 91.66667%;
  max-width: 91.66667%;
  padding: 0 15px;
}

.col-10 {
  flex: 0 0 83.33333%;
  max-width: 83.33333%;
  padding: 0 15px;
}

.col-9 {
  flex: 0 0 75%;
  max-width: 75%;
  padding: 0 15px;
}

.col-8 {
  flex: 0 0 66.66667%;
  max-width: 66.66667%;
  padding: 0 15px;
}

.col-7 {
  flex: 0 0 58.33333%;
  max-width: 58.33333%;
  padding: 0 15px;
}

.col-6 {
  flex: 0 0 50%;
  max-width: 50%;
  padding: 0 15px;
}

.col-5 {
  flex: 0 0 41.66667%;
  max-width: 41.66667%;
  padding: 0 15px;
}

.col-4 {
  flex: 0 0 33.33333%;
  max-width: 33.33333%;
  padding: 0 15px;
}

.col-3 {
  flex: 0 0 25%;
  max-width: 25%;
  padding: 0 15px;
}

.col-2 {
  flex: 0 0 16.66667%;
  max-width: 16.66667%;
  padding: 0 15px;
}

.col-1 {
  flex: 0 0 8.33333%;
  max-width: 8.33333%;
  padding: 0 15px;
}

@media (min-width: 576px) {
  .col-sm-12 {
    flex: 0 0 100%;
    max-width: 100%;
  }

  .col-sm-6 {
    flex: 0 0 50%;
    max-width: 50%;
  }

  .col-sm-4 {
    flex: 0 0 33.33333%;
    max-width: 33.33333%;
  }

  .col-sm-3 {
    flex: 0 0 25%;
    max-width: 25%;
  }
}

@media (min-width: 768px) {
  .col-md-12 {
    flex: 0 0 100%;
    max-width: 100%;
  }

  .col-md-8 {
    flex: 0 0 66.66667%;
    max-width: 66.66667%;
  }

  .col-md-6 {
    flex: 0 0 50%;
    max-width: 50%;
  }

  .col-md-4 {
    flex: 0 0 33.33333%;
    max-width: 33.33333%;
  }

  .col-md-3 {
    flex: 0 0 25%;
    max-width: 25%;
  }
}

@media (min-width: 992px) {
  .col-lg-12 {
    flex: 0 0 100%;
    max-width: 100%;
  }

  .col-lg-6 {
    flex: 0 0 50%;
    max-width: 50%;
  }

  .col-lg-4 {
    flex: 0 0 33.33333%;
    max-width: 33.33333%;
  }

  .col-lg-3 {
    flex: 0 0 25%;
    max-width: 25%;
  }
}

/* 工具类 */
.d-flex {
  display: flex;
}

.d-block {
  display: block;
}

.d-none {
  display: none;
}

.align-items-center {
  align-items: center;
}

.justify-content-center {
  justify-content: center;
}

.justify-content-between {
  justify-content: space-between;
}

.justify-content-end {
  justify-content: flex-end;
}

.text-center {
  text-align: center;
}

.text-end {
  text-align: right;
}

.text-decoration-none {
  text-decoration: none;
}

.position-relative {
  position: relative;
}

.position-absolute {
  position: absolute;
}

.py-3 {
  padding-top: 1rem;
  padding-bottom: 1rem;
}

.py-4 {
  padding-top: 1.5rem;
  padding-bottom: 1.5rem;
}

.py-5 {
  padding-top: 3rem;
  padding-bottom: 3rem;
}

.mt-3 {
  margin-top: 1rem;
}

.mt-4 {
  margin-top: 1.5rem;
}

.mt-auto {
  margin-top: auto;
}

.mb-0 {
  margin-bottom: 0;
}

.mb-3 {
  margin-bottom: 1rem;
}

.mb-4 {
  margin-bottom: 1.5rem;
}

.mb-5 {
  margin-bottom: 3rem;
}

.me-3 {
  margin-right: 1rem;
}

.ms-2 {
  margin-left: 0.5rem;
}

.bg-light {
  background-color: #f8f9fa;
}

.bg-dark {
  background-color: #343a40;
}

.text-light {
  color: #f8f9fa;
}

.text-primary {
  color: #007bff;
}

.text-muted {
  color: #6c757d;
}

.text-white {
  color: white;
}

.fw-bold {
  font-weight: bold;
}

.img-fluid {
  max-width: 100%;
  height: auto;
}

.rounded {
  border-radius: 0.375rem;
}

.btn-primary {
  background-color: #007bff;
  border-color: #007bff;
}

.btn-outline-primary {
  color: #007bff;
  border: 1px solid #007bff;
  background: transparent;
}

.btn-outline-primary:hover {
  background-color: #007bff;
  color: white;
}

.list-inline {
  list-style: none;
  padding: 0;
  margin: 0;
}

.list-inline-item {
  display: inline-block;
  margin-right: 0.5rem;
}

.list-unstyled {
  list-style: none;
  padding: 0;
}

.card-img-top {
  width: 100%;
}

.h-100 {
  height: 100%;
}

/* 响应式隐藏 */
@media (max-width: 767.98px) {
  .d-md-none {
    display: none !important;
  }

  .d-md-block {
    display: block !important;
  }
}

@media (min-width: 768px) {
  .d-none.d-md-block {
    display: block !important;
  }
}

@media (max-width: 991.98px) {
  .d-lg-none {
    display: none !important;
  }
}

@media (min-width: 992px) {
  .d-none.d-lg-block {
    display: block !important;
  }
}

/* 页脚样式 */
.footer {
  border-top: 1px solid #e9ecef;
  margin-top: auto;
}

/* 调整Element Plus样式 */
.el-carousel__container {
  border-radius: 0;
}

.el-carousel__item {
  border-radius: 0;
}

/* 文本截断省略号 */
.text-decoration-line-through {
  text-decoration: line-through;
}

/* 徽章样式 */
.badge {
  display: inline-block;
  padding: 0.25em 0.5em;
  font-size: 0.75em;
  font-weight: 700;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  vertical-align: baseline;
  border-radius: 0.375rem;
}

.bg-danger {
  background-color: #dc3545;
}

.bg-primary {
  background-color: #007bff;
}

.bg-success {
  background-color: #28a745;
}

.bg-warning {
  background-color: #ffc107;
}

.bg-info {
  background-color: #17a2b8;
}

.translate-middle {
  transform: translate(-50%, -50%);
}

.top-0 {
  top: 0;
}

.start-100 {
  left: 100%;
}

.bottom-0 {
  bottom: 0;
}

.start-0 {
  left: 0;
}

/* 移除了全局过渡动画 */
</style>